#include "widentifymanager.h"

WidentifyManager::WidentifyManager(QObject *parent) :
    QObject(parent)
{
    m_udpClient = new QUdpSocket(this);
#if 0
    m_udpClient->bind(QHostAddress::AnyIPv4, 80, QUdpSocket::ShareAddress);
    QHostAddress groupAddress("255.255.255.255");
    m_udpClient->joinMulticastGroup(groupAddress);

    connect(m_udpClient, SIGNAL(readyRead()), this, SLOT(processDatagrams()));
#endif
}

QString WidentifyManager::hostAddr()
{
    m_hostAddr = "Host Address Not Implemented";
    return m_hostAddr;
}

void WidentifyManager::setHostAddr(QString arg)
{
    if (m_hostAddr != arg) {
        m_hostAddr = arg;
        emit hostAddrChanged();
    }
}

void WidentifyManager::processDatagrams()
{
#if 0
    while (m_udpClient->hasPendingDatagrams()) {
        QByteArray datagram;
        datagram.resize(m_udpClient->pendingDatagramSize());
        m_udpClient->readDatagram(datagram.data(), datagram.size());
        qDebug() << (tr("Received datagram: \"%1\"").arg(datagram.data()));
    }
#endif
}
